package com.thunbu.thunbu_meeting_system.viewMdel

import androidx.lifecycle.MutableLiveData
import com.thunbu.lib_common.base.CoroutineViewModel
import com.thunbu.thunbu_meeting_system.await
import com.thunbu.thunbu_meeting_system.bean.ScanRegisterWapperModel
import com.thunbu.thunbu_meeting_system.launch
import com.thunbu.thunbu_meeting_system.service.ApiService
import com.thunbu.thunbu_meeting_system.service.MainNet
import com.thunbu.thunbu_meeting_system.toRequestBody

class ScanRegisterVM : CoroutineViewModel<Unit>() {
    val scanRegisterModel = MutableLiveData<ScanRegisterWapperModel>()

    override fun initModel() {

    }

    fun loadData(isDelete: Int, assetsName: String?, mPage: Int, originalPage: Int) {
        launch({
            val map = mutableMapOf<String,Any?>(
                    "isDelete" to isDelete,
                    "current" to mPage,
                    "pageSize" to originalPage
            )
            if(!assetsName.isNullOrEmpty()){
                map["assetsName"] = assetsName
            }
            val result = MainNet.server(ApiService::class.java).queryAppInventoryList(map.toRequestBody()).await(true,true)
            scanRegisterModel.value = result.data
        })
    }
}